/*
  Copyright 2011 Keith E. Laidig

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package org.aimj.tools;
/*
 * Centre.java
 * KEL
 * an object representing atom and function centres
 */
public class Centre {
    private double[] XYZ = new double[3];

    public Centre(Double X, Double Y, Double Z) {
        XYZ[0] = X;
        XYZ[1] = Y;
        XYZ[2] = Z;
    }

    // getters
    public double getX() {
        return XYZ[0];
    }
    public double getY() {
        return XYZ[1];
    }
    public double getZ() {
        return XYZ[2];
    }

    public double getL(int t) {
        //  return appropriate X, Y or Z term to provide angular momentum
	//  for the various atomic functions.  the terms, 't', are 1 -> X,
	//  2 -> Y or 3 -> Z in the calling scope but we map those to 
	//  0 -> X, 1 -> Y or 2 -> Z here, hiding this complexity from the
	//  calling scope...
        return XYZ[t - 1];  
    }

    // determine the distance from the Centre other to the origin of this object
    public double distance(Centre other) {
        return Math.sqrt( Math.pow((other.getX() - getX()), 2.0) +
                          Math.pow((other.getY() - getY()), 2.0) +
                          Math.pow((other.getZ() - getZ()), 2.0) );
    }

    // determine the distance squared from the Centre other to the origin of this object
    public double distanceSquared(Centre other) {
        return Math.pow((other.getX() - getX()), 2.0) +
               Math.pow((other.getY() - getY()), 2.0) +
               Math.pow((other.getZ() - getZ()), 2.0);
    }
	 public double getDelX(Centre other) {
	 	return other.getX() - getX();
	 }
	 public double getDelY(Centre other) {
	 	return other.getY() - getY();
	 }
	 public double getDelZ(Centre other) {
	 	return other.getZ() - getZ();
	 }

    public String toString() {
        return "(" + getX() + ", " + getY() + ", " + getZ() + ")";
    }
}
